<template>
  <div>
    <el-table :key="itemKey" :data="employeeList" style="width: 100%" border>

      <el-table-column label="员工编号" align="center" prop="number" min-width="120px" fixed="left" />
      <el-tree
        :props="props"
        :load="loadNode"
        lazy
        show-checkbox
        @check-change="handleCheckChange"
      />

    </el-table>
    <el-dialog title="编辑" :visible.sync="DialogVisible" width="60%" min-width="1035px">
      <el-form ref="form" label-width="80px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="班次">
              <el-input v-model="form.name" placeholder="" />
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="DialogVisible=false">取消</el-button>
        <el-button size="small" type="primary" @click="handleConfirm">确定</el-button>
      </span>
    </el-dialog>
  </div>

</template>
<script>

export default {
  components: {},
  data() {
    return {
      DialogVisible: false,
      form: {
        name: ''
      },
      employeeList: [
        {
          number: '122',
          employeeName: '飒飒'
        }
      ],
      TableHeaders: [
        {
          month: '08',
          day: 12,
          id: 1,
          weekValue: '周一'
        },
        {
          month: '08',
          day: 13,
          id: 2,
          weekValue: '周二'
        },
        {
          month: '08',
          day: 14,
          id: 3,
          weekValue: '周三'
        }
      ],
      curIndex: 0,
      curId: '',
      itemKey: '',
      curRow: {}
    }
  },
  computed: {

  },

  mounted() { // 挂载后
    // this.fetchData()
    this.getList()
  },

  methods: {
    getList() {
      this.TableHeaders.forEach((elt, index) => {
        this.employeeList.forEach(elt1 => {
          elt1['list' + elt.month + elt.day] = [{
            name: '早班0',
            id: 1
          }, {
            name: '中班0',
            id: 2
          }, {
            name: '晚班0',
            id: 3
          }]
        })
      })
      console.log(this.employeeList)
    },
    handleC(index, row, id) {
      this.curIndex = index
      this.curId = id
      this.curRow = row
      this.DialogVisible = true
      console.log(this.curRow)
    },
    handleConfirm() {
      this.employeeList.forEach(item => {
        item['list' + this.curRow.month + this.curRow.day].forEach(it => {
          if (it.id == this.curId) {
            it.name = this.form.name
          }
        })
        this.DialogVisible = false

        this.itemKey = Math.random()
        console.log(item['list' + this.curRow.month + this.curRow.day])
      })
    }

  }
}
</script>
